package com.anti.modular.bus.busrealestatefloor.controller;

import com.anti.commom.annotation.BusinessLog;
import com.anti.commom.annotation.Permission;
import com.anti.commom.enums.LogAnnotionOpTypeEnum;
import com.anti.commom.api.Result;
import com.anti.commom.pojo.BaseValidatedGroup;
import com.anti.jdbc.support.page.PageParam;
import com.anti.modular.bus.busrealestatefloor.param.BusRealEstateFloorParam;
import com.anti.modular.bus.busrealestatefloor.service.BusRealEstateFloorService;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;

import javax.annotation.Resource;

/**
 * 房产楼层表控制器
 *
 * @author anti
 * @date 2021-04-15 19:15:53
 */
@RestController
@RequestMapping("busRealEstateFloor")
public class BusRealEstateFloorController {

    @Resource
    private BusRealEstateFloorService busRealEstateFloorService;

    /**
     * 查询房产楼层表
     *
     * @author anti
     * @date 2021-04-15 19:15:53
     */
    @GetMapping("page")
    public Result page(PageParam pageParam, BusRealEstateFloorParam busRealEstateFloorParam) {
        return Result.data(busRealEstateFloorService.page(pageParam,busRealEstateFloorParam));
    }

    /**
     * 添加房产楼层表
     *
     * @author anti
     * @date 2021-04-15 19:15:53
     */
    @Permission
    @PostMapping("add")
    @BusinessLog(title = "房产楼层表_增加", opType = LogAnnotionOpTypeEnum.ADD)
    public Result add(@RequestBody @Validated(BusRealEstateFloorParam.add.class) BusRealEstateFloorParam busRealEstateFloorParam) {
            busRealEstateFloorService.add(busRealEstateFloorParam);
        return Result.success("新增成功");
    }

    /**
     * 删除房产楼层表
     *
     * @author anti
     * @date 2021-04-15 19:15:53
     */
    @Permission
    @PostMapping("delete")
    @BusinessLog(title = "房产楼层表_删除", opType = LogAnnotionOpTypeEnum.DELETE)
    public Result delete(@RequestBody @Validated(BusRealEstateFloorParam.delete.class) BusRealEstateFloorParam busRealEstateFloorParam) {
        return busRealEstateFloorService.delete(busRealEstateFloorParam);
    }

    /**
     * 编辑房产楼层表
     *
     * @author anti
     * @date 2021-04-15 19:15:53
     */
    @Permission
    @PostMapping("edit")
    @BusinessLog(title = "房产楼层表_编辑", opType = LogAnnotionOpTypeEnum.EDIT)
    public Result edit(@RequestBody @Validated(BusRealEstateFloorParam.edit.class) BusRealEstateFloorParam busRealEstateFloorParam) {
            busRealEstateFloorService.edit(busRealEstateFloorParam);
        return Result.success("修改成功");
    }

    /**
     * 查看房产楼层表
     *
     * @author anti
     * @date 2021-04-15 19:15:53
     */
    @GetMapping("detail")
    public Result detail(@Validated(BusRealEstateFloorParam.detail.class) BusRealEstateFloorParam busRealEstateFloorParam) {
        return Result.data(busRealEstateFloorService.detail(busRealEstateFloorParam));
    }

    /**
     * 房产楼层表列表
     *
     * @author anti
     * @date 2021-04-15 19:15:53
     */
    @GetMapping("list/{estateid}")
    public Result list(@PathVariable(name = "estateid") String estateid) {
        return Result.data(busRealEstateFloorService.list(estateid));
    }

    /**
     * 房产楼层表列表房產已擁有的
     *
     * @author anti
     * @date 2021-04-15 19:15:53
     */
    @GetMapping("busRealEstateFloorListForHave/{estateid}")
    public Result busRealEstateFloorListForHave(@PathVariable(name = "estateid") String estateid) {
        return Result.data(busRealEstateFloorService.busRealEstateFloorListForHave(estateid));
    }

}
